/**
 * 公共接口
 */

import { get, post, upload } from "@/utils/request";
import { get_perm } from "./tool";
/**
 * 获取系统字典
 * @param {*} type
 * @returns
 */
export const fetchDictOptions = (type) => {
  return get(`/dict/type?type=${type}`);
};

/**
 * 获取产品品类
 * @returns
 */
export const fetchProductCategory = () => {
  return get("/common/product/category");
};

/**
 * 商机搜索
 * @param {*} params
 * @returns
 */
export const fetchBusiness = (params) => {
  return get(get_perm("fetchBusiness"), params);
};

// /**
//  * 商机搜索-分总/区总
//  * @param {*} params
//  * @returns
//  */
// export const fetchBusinessByManage = (params) => {
//   return get("/business/search/manage", params);
// };

/**
 * 商机搜索-BD/BDM
 * @param {*} params
 * @returns
 */
// export const fetchBusinessByBd = (params) => {
//   return get(get_perm("fetchBusinessByBd"), params);
// };

/**
 * 商机搜索 - 权限整合
 * @param {*} params
 * @param {*} type lead 领导 manage 区总/分总 bd BD/BDM
 * @returns
 */
// export const fetchBusinessList = (params, type) => {
//   if (type === "lead") {
//     return fetchBusinessByLead(params);
//   } else if (type === "manage") {
//     return fetchBusinessByManage(params);
//   } else {
//     return fetchBusinessByBd(params);
//   }
// };

/**
 * 获取kp 列表
 * @param {*} params
 * @returns
 */
export const fetchKpList = (params) => {
  return get("/kp/list/boId", params);
};

/**
 * 获取oss上传签名链接
 * @param params
 * @returns {Promise}
 */
export const fetchOssUploadUrl = (params) => {
  return get("/oss/sign", params);
};
export const fetchOssupload = (params) => {
  return post("/oss/upload", params);
};

/**
 * 文件上传
 * @param params
 * @returns {Promise}
 */
export const fetchFileUpload = (url, params) => {
  return upload(url, params);
};
